﻿using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Text;

namespace Wfxin.SystemFramework.SystemLog
{
    public static class SystemLoggingServiceCollectionExtensions
    {
        public static IServiceCollection AddSystemLogging(this IServiceCollection services,Action<SystemLoggingOptions> action)
        {
            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }

            //Options and extension service
            var options = new SystemLoggingOptions();
            action(options);
            foreach (var serviceExtension in options.Extensions)
            {
                serviceExtension.AddServices(services);
            }
            services.AddSingleton(options);

            return services;
        }
    }
}
